package ddz;

import java.io.Serializable;

public class Pkp implements Serializable {
    private String showvlaue; //当setRealvalue的值确定后，则setShowvlaue的值不可以改变
    private int realvalue;
    private PkpStyle style;

    public String getShowvlaue() {
        return showvlaue;
    }

    private void setShowvlaue(String showvlaue) {
        this.showvlaue = showvlaue;
    }

    public Pkp(int realvalue, PkpStyle style) {
        
        setRealvalue(realvalue);//调用set方法，以便赋值
       
        if (realvalue == 16 || realvalue ==17){//判断牌是否为大小鬼
            this.style = null;
        }
        else {
            this.style = style;
        }
    }

    public int getRealvalue() {
        return realvalue;//返回真实值
    }

    private void setRealvalue(int realvalue) {

        if (realvalue < 3 || realvalue >17){
            System.out.println("赋值错误.");
            System.exit(0);
        }

        this.realvalue = realvalue;

        switch (realvalue){//确定每个数字对应的扑克牌
            case 11 :{
                this.showvlaue = "J";
                break;
            }

            case 12 :{
                this.showvlaue = "Q";
                break;
            }
            case 13 :{
                this.showvlaue = "K";
                break;
            }
            case 14 :{
                this.showvlaue = "A";
                break;
            }
            case 15 :{
                this.showvlaue = "2";
                break;
            }
            case 16 :{
                this.showvlaue = "小鬼牌";
                break;
            }
            case 17 :{
                this.showvlaue = "大鬼牌";
                break;
            }
            
            default:{
                this.showvlaue = realvalue + "";
            }

        }
    }

    public PkpStyle getStyle() {//获得扑克牌类型
        return style;
    }

    public void setStyle(PkpStyle style) {
        this.style = style;
    }

   @Override//重写toString类，打印出扑克牌
    public String toString() {
        return (style == null ? "" : style) + "" + this.showvlaue;
    }
}
